import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:gluz/app/modules/login/register_info/views/register_info_view.dart';
import 'package:gluz/app/modules/login/register_info/controllers/register_info_controller.dart';

void main() {
  group('RegisterInfoView Tests', () {
    late RegisterInfoController controller;

    setUp(() {
      controller = RegisterInfoController();
      Get.put(controller);
    });

    tearDown(() {
      Get.reset();
    });

    testWidgets('should display all required sections', (WidgetTester tester) async {
      await tester.pumpWidget(
        GetMaterialApp(
          home: const RegisterInfoView(),
        ),
      );

      // 验证所有必需的标题都存在
      expect(find.text('公司/个人名称'), findsOneWidget);
      expect(find.text('上传用户头像'), findsOneWidget);
      expect(find.text('选择国籍'), findsOneWidget);
      expect(find.text('所在地区'), findsOneWidget);
      expect(find.text('选择身份'), findsOneWidget);
      expect(find.text('确定'), findsOneWidget);
    });

    testWidgets('should display required indicators', (WidgetTester tester) async {
      await tester.pumpWidget(
        GetMaterialApp(
          home: const RegisterInfoView(),
        ),
      );

      // 验证必填标识
      expect(find.text('必填'), findsNWidgets(2)); // 公司名称和所在地区
      expect(find.text('必选'), findsOneWidget); // 身份选择
    });

    testWidgets('should display identity options', (WidgetTester tester) async {
      await tester.pumpWidget(
        GetMaterialApp(
          home: const RegisterInfoView(),
        ),
      );

      // 验证身份选项 - 使用Wrap布局后仍然应该能找到所有选项
      expect(find.text('供应商'), findsOneWidget);
      expect(find.text('采购商'), findsOneWidget);
      expect(find.text('货代公司'), findsOneWidget);
      expect(find.text('运输公司'), findsOneWidget);
      expect(find.text('服务商'), findsOneWidget);
      expect(find.text('翻译'), findsOneWidget);
    });

    testWidgets('should show warning message', (WidgetTester tester) async {
      await tester.pumpWidget(
        GetMaterialApp(
          home: const RegisterInfoView(),
        ),
      );

      // 验证警告信息
      expect(find.textContaining('注:身份、国籍确定后不可修改'), findsOneWidget);
    });
  });
} 